<template>
    <div class="orderDetailContainer">
        <HeaderBar title="订单详情" :isBack="true"></HeaderBar>
        <div class="orderDetailContent" v-if="orderInfo">
            <div class="orderItem">订单号：<span style="color: #666;font-weight: 400;">{{ orderInfo.Id }}</span></div>
            <div class="orderItem">订单状态：<span style="color: #666;font-weight: 400;">{{ orderInfo.OrderStatus==='Pending'?"待支付":'' }}</span></div>
            <div class="orderItem">下单时间：<span style="color: #666;font-weight: 400;">{{ orderInfo.CreateTime }}</span></div>
            <div class="orderItem"> 商品列表</div>
            <div class="orderDetailGoodsList">
                <div v-for="(item,index) in orderInfo.Items" :key="index" class="goodItem">
                    <img :src="item.Picture.NormalUrl" style="width: 40px;height: 40px;">
                    <div style="font-size: medium;" class="goodName">{{ item.Name }}</div>
                    <div style="font-size: medium;">x {{ item.Quantity }}</div>
                    <div style="color: red;">总价：{{ item.SubTotal }}</div>
                </div>
            </div>
            <div class="orderItem" style="font-size:large;text-align:  right;margin-top: 40px;">订单总价：<span style="color: red;">{{ orderInfo.OrderTotal }}</span></div>
            <div class="options">
                <div v-if="orderInfo.OrderStatus=='Pending'||orderInfo.OrderStatus=='Processing'" class="optionsItem" @click.stop="cancelOrder">取消订单</div>
                <!-- <div v-if="orderInfo.OrderStatus=='completed'" class="optionsItem" @click.stop="cancelOrder">售后</div> -->
            </div>
        </div>
        
    </div>
</template>
<script>
import { getOrderDetail } from "@/api/order";
import HeaderBar from "@/components/Header.vue";
export default {
    name: "orderDetail",
    components:{
        HeaderBar,
    },
    data() {
        return {
            orderInfo:null,
        };
    },
    methods: {
        cancelOrder(){
            // this.$router.push("/order");
        }
    },
    mounted(){
        getOrderDetail({oid:this.$route.query.id}).then((res)=>{
            this.orderInfo = res.Data;
        })
    }
    
}
</script>
<style scoped>
.orderDetailContainer{
    background-color: #950000;
    height: 100%;
    width: 100vw;
    display: flex;
    flex-direction: column;
}
.orderDetailContent {
        height: calc(100vh - 40px);
        overflow: auto;
        background-color: white;
    }
.orderItem{
    text-align: left;
    padding:0 10px;
    height: 40px;
    font-size: 14px;
    line-height: 40px;
    color: darkgray;
    font-weight: 600;
}
.goodItem{
    display: flex;
    justify-content: space-between;
    margin: 0 10px;
    height: 40px;
    line-height: 40px;
    font-size: 14px;
    color: #333;
    border-bottom: 1px solid #ccc;
}
.goodItem:last-child{
    border: none;
}
.goodName{
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.orderDetailGoodsList{
    margin: 0 10px;
    border: 2px solid #ccc;
    border-radius: 10px;
    padding: 10px 0;
}
.options{
    width: 100vw;
    height: 50px;
    background-color: #ededed;
    position: fixed;
    bottom: 0;
    display: flex;
    flex-direction: row-reverse;
    padding: 0 10px;
    align-items: center;
}
.optionsItem{
    height: 50px;
    width: 120px;
    font-size: medium;
    color: white;
    background-color: #950000;
    line-height: 50px;
    margin-left: 10px;
}
</style>